<template>
  <div class="teamBuyInfo">
    <van-skeleton title :loading="loading" :row="20">
      <van-nav-bar
        title="详情"
        left-text="返回"
        right-text="分享"
        left-arrow
        :fixed="true"
        :placeholder="true"
        @click-left="$router.back(-1)"
        @click-right="Share"
      >
        <!-- <template #right class="share-title">
          <van-icon name="share-o" size="18" @click="showShare = true" />
          
        </template> -->
      </van-nav-bar>
      <!-- <van-swipe class="my-swipe" :autoplay="5000" lazy-render>
        <van-swipe-item v-for="image in item.F_pic_url" :key="image">
          <img :src="image" />
        </van-swipe-item>
      </van-swipe> -->
      <div class="product-img">
        <img :src="'http://higuang365.com/' + item.F_pic_url" />
      </div>
      <div class="information">
        <div class="group-warp">
          <div class="module-wrap J_mod3">
            <div class="module-price">
              <div class="real-price">
                <span class="ui-yen"
                  ><i class="price-symbol">¥</i
                  ><span class="price">{{ isPromotion?item.F_FxPrice: item.F_BdPrice }}</span></span
                >
                <span class="icon-text">{{isPromotion?'限时促销':'品牌钜惠'}}</span>
              </div>
              <div class="item-price" v-if="item.F_Price!=item.F_BdPrice">
                <del>¥{{ item.F_Price }}</del>
              </div>
            </div>
            <div class="module-time" v-if="countDown">
              <img
                src="//image3.suning.cn/uimg/cms/img/161102287599339361.png"
                alt=""
                class="miaosha-logo"
              />
              <div
                data-v-650e4c98=""
                class="time-info"
               
              >
                距结束仅剩
              </div>
              <van-count-down
                :time="time"
                @finish="onFinish"
              >
                <template #default="timeData">
                  <span class="block">{{ timeData.hours+timeData.days*24 }}</span>
                  <span class="colon">:</span>
                  <span class="block">{{ timeData.minutes }}</span>
                  <span class="colon">:</span>
                  <span class="block">{{ timeData.seconds }}</span>
                </template>
              </van-count-down>
            </div>
            <div class="module-time"  style="color: rgb(234, 48, 48)" v-else>已结束</div>
          </div>
          <div class="module-wrap" id="J_mod4">
            <div class="module-from"></div>
          </div>
          <div class="module-wrap" id="J_mod5">
            <div class="module-title">
              <div class="share-warp">
                <div class="mui-flex">
                  <div class="main cell">
                    {{ item.F_Name }}
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="module-wrap" id="J_mod6">
            <div class="module-adds">
              <!-- <span class="postage">快递: 免运费</span> -->

              <!-- <span class="sales">月销量 {{item.F_yuliu3*8}}件</span> -->

              <div class="delivery" v-if="item.F_yuliu2">
                <img :src="'http://higuang365.com/' + item.F_yuliu2" />
                <div>{{ item.F_BrandCountrie }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="gap"></div>
      <!-- <van-sticky :offset-top="46"> -->
      <div class="mod_tab">
        <div
          class="J_ping item"
          @click="modtab = 'details'"
          :class="{ cur: modtab === 'details' }"
        >
          商品介绍
        </div>
        <!-- <div
            class="J_ping item"
            @click="modtab = 'Spec'"
            :class="{ cur: modtab === 'Spec' }"
          >
            规格参数
          </div> -->
        <!-- <div
            class="J_ping item"
            @click="modtab = 'Aftersales'"
            :class="{ cur: modtab === 'Aftersales' }"
          >
            售后保障
          </div> -->
      </div>
      <!-- </van-sticky> -->
      <div class="details" v-html="item.F_yuliu4"></div>
      <div class="tips">
        划线价格：指商品的专柜价、吊牌价、正品零售价、厂商指导价或该商品的曾经展示过的销售价等，并非原价，仅供参考。<br />
        未划线价格：指商品的实时标价，不因表述的差异改变性质。具体成交价格根据商品参加活动，或使用优惠券、积分等发生变化，最终以订单结算页价格为准。
      </div>
      <!-- <img v-for="image in banner" :key="image" :src="image"/> -->
      <!-- <div class="Spec" v-if="modtab === 'Spec'">
        <div><span>品牌：</span>{{ item.brandName }}</div>
        <div><span>重量：</span>{{ item.weight }}</div>
        <div>
          <span>款式：</span
          ><span v-for="Seq in item.salePropSeq" :key="Seq">{{ Seq[0] }}</span>
        </div>
      </div> -->

      <van-action-bar>
        <van-action-bar-icon
          icon="chat-o"
          text="客服"
          color="#ee0a24"
          @click="customer"
        />
        <van-action-bar-icon
          icon="cart-o"
          text="购物车"
          @click="toCart"
          :badge="$store.state.cartNum"
          :show-zero="false"
        />
        <van-action-bar-button
          type="danger"
          text="马上抢"
          @click="
            goBuys($route.query.parents_id, item.F_yuliu3, item.F_ProductId,true,1)
          "
          v-if="countDown"
        />
         <van-action-bar-button
          type="danger"
          text="已结束"
          v-else
        />
        
        <!-- </div> -->

        <!--  -->
      </van-action-bar>
    </van-skeleton>

    <van-overlay :show="showShare" @click="showShare = false" z-index="100">
      <div class="wrapper" @click.stop>
        <van-icon name="share-o" size="100" @click="showShare = true" />
        <div class="sharetips">分享给你的朋友</div>
        <!-- <img class="block" src="//bpic.588ku.com/element_origin_min_pic/19/04/23/a115a1dee787538a628d0220c42bfc57.jpg"/> -->
      </div>
    </van-overlay>
  </div>
</template>

<script>
import { reactive, toRefs } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getSpecialGoodsInfoList } from "@/api/home";
import { getCookie, addBuys, goBuys,wxapi } from "@/lib/ecapi";
export default {
  name: "teamBuyInfo",
  setup() {
    const data = reactive({
      banner: [],
      price: 0,
      name: "",
      item: {},
      modtab: "details",
      showShare: false,
      loading: true,
      star: true,
      sharewx: [],
      time:"",
      countDown:true,
      isPromotion:false,
    });
    const route = useRoute();
    const router = useRouter();
    const { id } = route.query;

    const customer = () => {
      window.location.href =
        "http://qfck70.kuaishang.cn/bs/im.htm?cas=3514___580971&fi=4006";
    };
    const Share = () => {
      if (!getCookie("S[MEMBER]")) {
        window.location.href = "http://www.higuang365.com/wap/passport.html";
        return;
      }
      let msg = {
        title: "嗨逛全球", //标题
        content: data.item.F_Name, //内容
        purl: "http://www.higuang365.com/" + data.item.F_pic_url, //可以是本地图片
        surl:
          "http://www.higuang365.com/wap/#/teamBuyInfo?id=" +
          data.item.F_ProductId +
          "&parents_id=" +
          data.item.F_yuliu1, //分享的链接
      };
      if (navigator.userAgent.indexOf("haiguang_mobile") > -1) {
        window.location.href = `higuang|shareGood|${msg.title}|${msg.content}|${msg.purl}|${msg.surl}`;
      } else {
        data.showShare = true;
      }
    };
    const toCart = () => {
      window.location.href = "http://www.higuang365.com/wap/cart.html";
    };
    const load = async () => {
      const res = await getSpecialGoodsInfoList({
        goodsid: id,
        member_id: getCookie("S[MEMBER]"),
        Strlv: getCookie("MLV"),
      });
      data.loading = false;
      data.item = res[1][0];
      // router.replace({ query:{ id: id, parents_id: 111 }});
      if (getCookie("S[MEMBER]")) {
        router.replace({ query: { id: id, parents_id: data.item.F_yuliu1 } });
      }
      // data.time=new Date(data.item.F_yuliu10.replace(/\//g, '/')).getTime()-new Date().getTime();
      data.time=new Date(data.item.F_yuliu10).getTime()-new Date().getTime();
      wxapi("嗨逛全球",data.item.F_Name,"http://www.higuang365.com/wap/#/teamBuyInfo?id=" +
          data.item.F_ProductId +
          "&parents_id=" +
          data.item.F_yuliu1, "http://www.higuang365.com/" + data.item.F_pic_url);
      data.isPromotion=new Date().getTime()<= new Date(data.item.F_yuliu10).getTime()&&new Date().getTime()>= new Date(data.item.F_yuliu9).getTime()&&data.item.F_yuliu8;

    };
    const onFinish=()=>{
      data.countDown=false;
    };
    load();
    return { ...toRefs(data), customer, addBuys, Share, goBuys, toCart, onFinish };
  },
};
</script>
<style lang="scss" scoped>
@import "@/common/style/mixin";
.teamBuyInfo {
  font-size: 1.5rem;
}
.my-swipe {
  height: 100vw;
  img {
    width: 100vw;
    height: 100vw;
  }
}
.product-img {
  height: 100vw;
}
.information {
  text-align: left;
}
.gap {
  width: 100%;
  height: 1rem;
  background: #f5f5f5;
}
.module-title {
  margin: 1rem 0;
  font-weight: bold;
}
.J_mod3 {
  display: flex;
}
.module-price {
  background: linear-gradient(90deg, #ed4747, #ef2525);
  padding: 1rem;
  flex: 3;
  .real-price {
    color: #fff;
    height: 3.6rem;
    line-height: 3.6rem;
    .ui-yen .price-symbol {
      font-family: arial;
      font-style: normal;
      font-size: 1.8rem;
      position: relative;
      top: 2px;
    }
    .ui-yen .price {
      font-size: 2.4rem;
      position: relative;
      top: 2px;
      margin-right: 0.5rem;
    }
    .icon-text {
      background-color: #fb6878;
      color: #fff;
      font-size: 1.2rem;
      padding: 1px 2px;
    }
  }
  .item-price {
    font-size: 1.2rem;
    height: 2rem;
    line-height: 2rem;
    color: #fff;
    display: inline-block;
    margin-right: 1rem;
    font-family: "\5fae\8f6f\96c5\9ed1";
  }
}

.module-time {
  display: flex;
  flex: 1;
  min-width: 9rem;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 0.5rem 2rem;
  background: #fef2f1;
  text-align: center;
  .miaosha-logo {
    height: auto;
  }
  .colon {
    display: inline-block;
    margin: 0 2px;
    color: #222;
  }
  .block {
    width: 1.8rem;
    height: 1.8rem;
    margin: .2rem;
    display: inline-block;
    border-radius: 3px;
    color: #fff;
    font-size: 1rem;
    text-align: center;
    background-color: #222;
  }
  .time-info {
    color: rgb(234, 48, 48);
    font-size: 1rem;
  }
}
.module-title .share-warp {
  padding: 3px 10px 0 !important;
  background-color: #fff;
}

.mui-flex {
  display: flex;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}
.module-title .main {
  font-size: 1.4rem;
  color: #051b28;
  line-height: 2rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  max-height: 6.3rem;
  -webkit-box-orient: vertical;
  -webkit-box-pack: center;
  overflow: hidden;
  word-break: break-all;
}
.mui-flex > .cell {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
  width: 0;
  -webkit-flex-basis: 0;
  -ms-flex-preferred-size: 0;
  flex-basis: 0;
  max-width: 100%;
  display: block;
  padding: 0 !important;
  position: relative;
}
.module-adds {
  display: -webkit-box;
  display: flex;
  background-color: #fff;
  padding: 0.5rem 1rem;
  font-size: 1.2rem;
  color: #999;
  justify-content: space-between;

  .delivery {
    display: flex;
    img {
      width: 2rem;
    }
  }
}
.Spec {
  div {
    border: 1px solid;
  }
}
.details {
  min-height: 600px;
  margin-bottom: 2rem;
}
.mod_tab {
  display: flex;
  background: #fff;
  .item {
    flex: 1;
    height: 3.6rem;
    line-height: 2.2rem;
    padding-top: 1.5rem;
  }
  .item.cur {
    position: relative;
    font-weight: 700;
    color: #262626;
  }
  .item.cur:after {
    position: absolute;
    left: 50%;
    bottom: 6px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    content: "";
    display: block;
    width: 2.6rem;
    height: 3px;
    background-image: -webkit-gradient(
      linear,
      left top,
      right top,
      from(#f5503a),
      to(#fad1cb)
    );
    background-image: -webkit-linear-gradient(left, #f5503a, #fad1cb);
    background-image: linear-gradient(90deg, #f5503a, #fad1cb);
  }
}
.tips {
  font-size: 1.2rem;
  margin-bottom: 5rem;
}
.wrapper {
  i {
    color: #fff;
    transform: translate3d(12rem, 20px, 0px) rotate3d(30, -24, 0, 180deg);
  }
  .sharetips {
    color: #fff;
    font-size: 2rem;
  }
}
</style>